package lab03.test07;

import java.io.*;
import java.util.zip.*;

/**
 * 	读取book.zip,并将book.zip中含有的文件重新存放到当前目录中的book文件夹中，
 * 即将book.zip的内容解压到book文件夹中。
 */
public class Test {
    public static void main(String[] args) {
        File f=new File("book.zip");
        File dir=new File("mybook");
        byte b[]=new byte[100];
        dir.mkdir();

        ZipInputStream in= null;
        try {
            in = new ZipInputStream(new FileInputStream(f));
            ZipEntry zipEntry=null;
            while ((zipEntry=in.getNextEntry())!=null){
                File file=new File(dir,zipEntry.getName());
                FileOutputStream out=new FileOutputStream(file);
                int n=-1;
                System.out.println(file.getAbsolutePath()+"的内容");
                while ((n=in.read(b,0,100))!=-1) {
                    String str = new String(b, 0, n);
                    System.out.println(str);
                    out.write(b, 0, n);
                }
                out.close();
                }
                in.close();
        } catch (IOException ee) {
            System.out.println(ee);
        }
    }
}
